from nltk.tokenize import sent_tokenize
from nltk.tokenize import word_tokenize
from nltk.corpus import wordnet
from nltk.stem import PorterStemmer

def test_tokenize():

	thetext = "Hello Adam, how are you? I hope everything is going well. Today is a good day, see you dude"
	chtext = "你好，这里是中国。一个伟大的国度！"
	print(sent_tokenize(thetext))
	#print(sent_tokenize(chtext, "china"))

	print(word_tokenize(chtext))

def test_wordnet(word):
	syn = wordnet.synsets(word)
	print(syn[0].definition())
	print(syn[0].examples())

def test_get_wordnet(word):
	synonyms = []
	for syn in wordnet.synsets(word):
		for lemma in syn.lemmas():
			synonyms.append(lemma.name())
	print(synonyms)

def test_antonyms(word):
	antonyms = []
	for syn in wordnet.synsets(word):
		for l in syn.lemmas():
			if l.antonyms():
				antonyms.append(l.antonyms()[0].name())
	print(antonyms)

def test_stemmer():
    stemmer = PorterStemmer()
    print(stemmer.stem('working'))
    print(stemmer.stem('worked'))

#test_wordnet("Python")
#test_get_wordnet("computer")
#test_antonyms("small")
test_stemmer()
